package club.emergency.wechat.staff.search.consumer.service.fallback_factory;

import club.emergency.wechat.common.response.ResponseEntity;
import club.emergency.wechat.common.response.StatusCode;
import club.emergency.wechat.staff.search.consumer.service.StaffSearchConsumer;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * Create with IntelliJ IDEA
 * Project Name: wechat
 * Package Name: club.emergency.wechat.staff.search.consumer.service.fallback_factory
 * Date: 2019/3/25
 *
 * @author: 快乐的小菌菌
 * Description:
 */
@Component
public class StaffSearchFallbackFactory implements FallbackFactory<StaffSearchConsumer> {
    @Override
    public StaffSearchConsumer create(Throwable throwable) {
        return new StaffSearchConsumer() {
            @Override
            public String flipList(Integer pageNo, Integer pageSize) {
                return ResponseEntity.error(StatusCode.DB_SEARCH_ERROR,"按条件查询用户列表失败！",throwable.getMessage());
            }

            @Override
            public String signature(String openId) {
                return ResponseEntity.error(StatusCode.DB_SEARCH_ERROR,"登录失败！",throwable.getMessage());
            }

            @Override
            public String updateToken() {
                return ResponseEntity.error(StatusCode.DB_SEARCH_ERROR,"更新Token失败！",throwable.getMessage());
            }

            @Override
            public String getById(Long id) {
                return ResponseEntity.error(StatusCode.DB_SEARCH_ERROR,"根据id查询用户失败！",throwable.getMessage());
            }

            @Override
            public String checkEachTest(Long id) {
                return ResponseEntity.error(StatusCode.DB_SEARCH_ERROR,"检查每日答题是否完成失败！",throwable.getMessage());
            }
        };
    }
}
